package zhongbo.java.air.monitor.web.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import zhongbo.java.air.common.vo.PageVo;
import zhongbo.java.air.common.vo.ResultVo;
import zhongbo.java.air.monitor.model.AirAlertLog;
import zhongbo.java.air.monitor.service.IAirAlertLogService;

/**
 * 说明：
 *
 * @author 钟波dellNotebook
 * @since 2025年04月09日 星期三 23:43:45
 */
@RestController
@RequestMapping("alertLog")
@Api(tags = "告警日志记录")
public class AlertLogController {

    @Autowired
    private IAirAlertLogService alertLogService;

    // to//do 今日周二待做, 标准crud接口(包括分页)

    @PostMapping("add")
    @ApiOperation("添加")
    ResultVo<AirAlertLog> add(@RequestBody AirAlertLog entity) {
        AirAlertLog alertLog = alertLogService.add(entity);
        return ResultVo.ok(alertLog);
    }

    @GetMapping("delete")
    @ApiOperation("删除")
    ResultVo<String> delete(String entityId) {
        String delete = alertLogService.delete(entityId);
        return ResultVo.ok(delete);
    }

    @PostMapping("edit")
    @ApiOperation("修改")
    ResultVo<AirAlertLog> edit(@RequestBody AirAlertLog edit) {
        AirAlertLog alertLog = alertLogService.edit(edit);
        return ResultVo.ok(alertLog);
    }

    @GetMapping("findOne")
    @ApiOperation("查询一条")
    ResultVo<AirAlertLog> findOne(String entityId) {
        AirAlertLog alertLog = alertLogService.findOne(entityId);
        return ResultVo.ok(alertLog);
    }

    @GetMapping("findPage")
    @ApiOperation("分页查询列表")
    ResultVo<PageVo<AirAlertLog>> findPage(Integer page, Integer pageSize
            , String icao, String startDate, String endDate
            , String keyword, String fields
            , String oderByField, Boolean orderByAsc) {
        PageVo<AirAlertLog> pageVo = alertLogService.findPage(
                 icao, startDate, endDate,
                 keyword, fields, page, pageSize,oderByField, orderByAsc);
        return ResultVo.ok(pageVo);
    }

}

